//
//  SNOrderFormDetailViewController.m
//  app
//
//  Created by 王少宁 on 15/5/6.
//  Copyright (c) 2015年 hdaren. All rights reserved.
//  订单性情

#import "SNOrderFormDetailViewController.h"
#import "SNOrderFormDetailDataManager.h"
#import "SNOrderFormHeaderView.h"
#import "SNOrderFormDetailAdressCell.h"
#import "SNOrderFormDetailBasicCell.h"
#import "SNOrderFormDetailGoodsCell.h"
#import "SNOrderFormListFooterView.h"
#import "SNExpressHabitViewController.h"
#import "SNOrderFormFooterView.h"
#import "SNWritePresentationView.h"
#import "SNAddCommentsViewController.h"
#import "SNReturnGoodsViewController.h"
#import "SNReturnGoodsRepetitiousViewController.h"
#import "HZCartsListViewController.h"
/** 点击了礼物*/
#import "HZProductGiftListView.h"
//支付宝支付
#import <AlipaySDK/AlipaySDK.h>
//微信支付
#import "WXApi.h"
#import "CommonUtil.h"
/** 聊天界面*/
#import"HDChatOBO.h"
/** 商品详情*/
#import "HZGoodsDetailViewController.h"

#define kZFBPayResultSuccess @"订单支付成功"
#define kZFBPayResultWaiting @"等待支付结果返回中,请稍后查看"

@interface SNOrderFormDetailViewController ()<UIAlertViewDelegate,UITableViewDataSource,UITableViewDelegate,OrderFormDetailAdressCellDeletage,OrderFormDetailBasicCellDeletage,SNOrderFormFooterViewDeletage,PAYBtnClickDeletage,OrderFormDetailGoodsCellDeletage>
@property (nonatomic, retain) UITableView * myTableView;
@property (nonatomic, retain) SNOrderFormDetailHttpResult * result;
@property (nonatomic, retain) SNOrderFormDetailDataManager * manager;
@property (nonatomic, retain) SNWXSignHttpResult * wxResult;
@property (nonatomic, retain) SNOrderWXSignDataManager * wxManager;
@property (nonatomic, assign) int viewApperaCount;
/** 是否有发票信息*/
@property (nonatomic, assign) BOOL invoiceInfo;

@end

@implementation SNOrderFormDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationController.navigationBar.hidden = NO;
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.navigationItem.title = @"订单详情";
    [self createBackBtnAndChatBtn];
    self.viewApperaCount = 0;
    self.result = [[SNOrderFormDetailHttpResult alloc] initWithTarget:self action:@selector(loadingData:)];
    self.manager = [SNOrderFormDetailDataManager shareManager];
    [self createScrollView];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(zfbPayResultWithNotification:) name:@"ZFBPayResultNotification" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(wxPayResultWithNotification:) name:@"WXPayResultNotification" object:nil];
}

- (void)createBackBtnAndChatBtn
{
    UIButton * backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    backBtn.frame = CGRectMake(0, 20, 100, 40);
    [backBtn setImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"ic_actionbar_home_up@2x" ofType:@"png"]] forState:UIControlStateNormal];
    backBtn.imageEdgeInsets = UIEdgeInsetsMake(0, -105, 0, 0);
    [backBtn addTarget:self action:@selector(popToOrderFormDetailVC) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem * backBtnItem = [[UIBarButtonItem alloc] initWithCustomView:backBtn];
    self.navigationItem.leftBarButtonItem = backBtnItem;
    
//    UIButton * chatBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//    chatBtn.frame = CGRectMake( SCREEN_WIDTH - 70, 20, 55, 40);
//    chatBtn.titleLabel.font = JKAppGlobleFontMinTagText;
//    [chatBtn setTitle:@"咨询客服" forState:UIControlStateNormal];
//    [chatBtn setTitleColor:[XCommon hexStringToColor:kColor_red_text]  forState:UIControlStateNormal];
//    [chatBtn addTarget:self action:@selector(chatBtnClick) forControlEvents:UIControlEventTouchUpInside];
//    UIBarButtonItem * chatBtnItem = [[UIBarButtonItem alloc] initWithCustomView:chatBtn];
//    self.navigationItem.rightBarButtonItem = chatBtnItem;
}

- (void)popToOrderFormDetailVC
{
    if ([self.popToVCNameStr isEqualToString:@"HZOrderConfirmViewController"]) {
        
        for (UIViewController *temp in self.navigationController.viewControllers) {
            if ([temp isKindOfClass:[HZCartsListViewController class]]) {
                [self.navigationController popToViewController:temp animated:YES];
            }
        }
    } else {
        [self.navigationController popViewControllerAnimated:YES];
    }
    
}

- (void)chatBtnClick
{
    
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
    self.navigationController.navigationBar.hidden = NO;
    
    [self requestWithSn:self.sn];
    self.viewApperaCount++;
}

- (void)createScrollView
{
    self.myTableView = CREATE_WITH_FRAME_OF(UITableView, CGPointMake(0, 0),
                                            [self.view.ubo ow:SCREEN_WIDTH oh:ScreenHeight],
                                            style:UITableViewStyleGrouped);
    self.myTableView.contentInset = UIEdgeInsetsMake(self.navigationAndStatusBarHeight, 0, 0, 0);
    self.myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.myTableView.separatorColor = [UIColor clearColor];
    self.myTableView.dataSource = self;
    self.myTableView.delegate = self;
    self.myTableView.sectionHeaderHeight = 0;
    self.myTableView.sectionFooterHeight = 0;
    self.myTableView.headerRefreshController = [[UIRefreshHeaderController alloc] initWithTableView:self.myTableView caller:[UBTargetCaller of:self action:@selector(refreshData)]];
    self.myTableView.nothingRefreshView = [[UIRefreshNotingRefreshView alloc] initWithView:self.view viewController:self tryAgain:@selector(refreshData)];
    [self.view addSubview:self.myTableView];
}

- (void)refreshData
{
    [self requestWithSn:self.sn];
}

- (void)requestWithSn:(NSString *)sn
{
    if (self.viewApperaCount == 0) {
        [self.myTableView.nothingRefreshView show];
    }
    [self.manager loadOrderFormDetailData:self.result sn:sn];
}

- (void)loadingData:(SNOrderFormDetailHttpResult *)result
{    
    if (result.success) {
        [self.myTableView endRefreshingAll];
        [self.myTableView.nothingRefreshView remove];
        
        [self createHeaderView];
        
        if ([result.model.basicModel.invoice_name isEqualToString:@"无"]) {
            self.invoiceInfo = NO;
        } else {
            self.invoiceInfo = YES;
        }
        
        [self createFooterView];
        
        [self.myTableView reloadData];
    } else if (result.failure) {
        [self.myTableView.nothingRefreshView activeStop];
    }
}

- (void)createHeaderView
{
    SNOrderFormHeaderView * view = [[SNOrderFormHeaderView alloc] init];
    view.frame = CGRectMake(0, 0, SCREEN_WIDTH, 150);
    if ([self.result.model.ostatus intValue] == 0) {
        view.style = OrderFormNonPay;
    } else {
        view.style = OrderFormPay;
    }
    
    view.deletage = self;
    [view viewWithModel:self.result.model];
    self.myTableView.tableHeaderView = view;
}

- (void)createFooterView
{
    int ostatus = [self.result.model.ostatus intValue];

    SNOrderFormFooterView * view = [[SNOrderFormFooterView alloc] initWithType:ostatus];
    view.frame = CGRectMake(0, 0, SCREEN_WIDTH, kOrderFormFooterViewHeight);
    view.deletage = self;
    self.myTableView.tableFooterView = view;

}

#pragma mark - UITableViewDeletage
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 3;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section == 0) {
        return 1;
    } else if (section == 1) {
        return 1;
    } else {
        return self.result.model.productArray.count;
    }
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0) {
        SNOrderFormDetailAdressCell * cell = [[SNOrderFormDetailAdressCell alloc] init];
        cell.deletage = self;
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        [cell cellWithModel:self.result.model.receiverInfoModel];
        return cell;
    } else if (indexPath.section == 1) {
        static NSString * identifier = @"basicCell";
        SNOrderFormDetailBasicCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
        if (cell == nil) {
            cell = [[SNOrderFormDetailBasicCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
            cell.deletage = self;
        }
        [cell cellWithModle:self.result.model.basicModel row:indexPath.row invoiceInfo:self.invoiceInfo];
        return cell;
    } else {
        static NSString * identifier = @"listCell";
        SNOrderFormDetailGoodsCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
        if (cell == nil) {
            cell = [[SNOrderFormDetailGoodsCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
            cell.deletage = self;
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
        }
        [cell cellWithModel:self.result.model.productArray[indexPath.row] row:indexPath.row];
        return cell;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0) {
        return self.result.model.receiverInfoModel.cellHeight;
    } else if (indexPath.section == 1) {
        return kOrderFormDetailBasicCellHeight;
    } else {
        SNOrderFormDetailGoodsModel * model = self.result.model.productArray[indexPath.row];
        return model.cellHeight;
    }
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    if (section == 2) {
        SNOrderFormListFooterView * footerView = [[SNOrderFormListFooterView alloc] init];
        [footerView viewWithModel:self.result.model.footerModel];
        return footerView;
    } else {
        return nil;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (section == 1) {
        return 0;
    } else {
        return 15;
    }
//    return 15;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    if (section == 2) {
        return kOrderFormListFooterViewHeight;
    } else {
        return 0;
    }
}

#pragma mark - 点击了 收货人
-(void)orderFormDetailAdressCellClick
{
    DLog(@"点击了 收货人");
}

#pragma mark - 点击了物流信息
- (void)orderFormDetailExpressCellClick
{
    DLog(@"点击了 物流信息");
}

#pragma mark - 点击了 配送时间,发票信息,买家留言
- (void)orderFormDetailBasicCellClickWithRow:(NSString *)row string:(NSString *)string
{
    [[SNWritePresentationView shareView] viewWithController:self string:string];
}

#pragma mark - 点击了 取消订单或者联系客服
- (void)footViewClickWithBtnTitle:(NSString *)btnTitle
{
    if ([btnTitle isEqualToString:kCancleOrderBtnTitle]) {//取消订单
        
        UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:@"提示" message:@"确认取消订单" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:@"取消", nil];
        [alertView show];
        
    } else if ([btnTitle isEqualToString:kChatWithSeverBtnTitle]) {//联系客服
        
#pragma mark - 联系客服
        HDChatOBO * chatOBOVC = [[HDChatOBO alloc] init];
        //客服id
        chatOBOVC.chat_people_uid = self.result.model.custonmerServiceModel.uid;
        //客服名字
        chatOBOVC.chat_people_name = self.result.model.custonmerServiceModel.nickName;
        //客服头像
        chatOBOVC.chat_people_face = self.result.model.custonmerServiceModel.face;
        //订单编号
        chatOBOVC.reserve_number = self.sn;
        //订单价格
        chatOBOVC.reserve_price = self.result.model.money;
        //订单状态
        switch ([self.result.model.ostatus intValue]) {
            case 0:
                chatOBOVC.reserve_status = @"未支付";
                break;
            case 1:
                chatOBOVC.reserve_status = @"支付成功";
                break;
            case 2:
                chatOBOVC.reserve_status = @"已发货";
                break;
            case 4:
                chatOBOVC.reserve_status = @"已完成";
                break;
            case 5:
                chatOBOVC.reserve_status = @"已失效";
                break;
            case 6:
                chatOBOVC.reserve_status = @"订单取消";
                break;
            case 8:
                chatOBOVC.reserve_status = @"备货中";
                break;
            case 9:
                chatOBOVC.reserve_status = @"备货中";
                break;
            default:
                break;
        }
        
        //isShop
        chatOBOVC.isShop = @"2";
        
        [self.navigationController pushViewController:chatOBOVC animated:YES];
    }
}

#pragma mark - 取消订单的回调 : 将商品添加到购物车
- (void)cancleOrderLoad:(SNCancleOrderHttpResult *)result
{
    if (result.success) {//已经成功取消订单,还需要将取消订单的商品添加到购物车
        
        //获取需要取消的订单列表中的商品(可能有多个)信息组成的数组 [{"act_id":1,"shop_id":3,"product_id":5,"num":45},{"act_id":2,"shop_id":3,"product_id":5,"num":45}]
        NSMutableString * string = [[NSMutableString alloc] initWithString:@"["];
        
        for (int i = 0; i < self.result.model.productArray.count; i++) {
            
            SNOrderFormDetailGoodsModel * model = self.result.model.productArray[i];
            
            if (i == self.result.model.productArray.count-1) {//最后一个不需要拼接','
                NSDictionary * dic = [[NSDictionary alloc] initWithObjectsAndKeys:model.act_id,@"act_id",model.shop_id,@"shop_id",model.product_id,@"product_id",model.product_num,@"num", nil];
                [string appendString:[NSString stringWithFormat:@"%@",[dic JSONString]]];
            } else {
                NSDictionary * dic = [[NSDictionary alloc] initWithObjectsAndKeys:model.act_id,@"act_id",model.shop_id,@"shop_id",model.product_id,@"product_id",model.product_num,@"num", nil];
                [string appendString:[NSString stringWithFormat:@"%@,",[dic JSONString]]];
            }
        }
        
        [string appendString:@"]"];
        
        SNAddGoodsToCarOrderHttpResult * result = [[SNAddGoodsToCarOrderHttpResult alloc] initWithTarget:self action:@selector(addGoodsToCar:)];
        //发送 将商品 添加到购物车的请求
        [self.manager requestCancleAndAddGoodsToCarWithResult:result goodsArray:string];

    }
}

#pragma mark - 将物品添加到购物车之后的回调
- (void)addGoodsToCar:(SNCancleOrderHttpResult *)result
{
    if (result.success) {//已经成功的将取消订单的商品添加到了购物车
        //发送通知告诉购物车应该刷新一次
        [[NSNotificationCenter defaultCenter] postNotificationName:kNotificationCartsRefresh object:nil];
        
        //蒙板消失
        [MBProgressHUD dismissMBProgressHUBOnWindows];
        //重新加载订单性情页面,改变订单状态
        [self.manager loadOrderFormDetailData:self.result sn:self.result.model.sn];
    } else {
        
    }
}

#pragma mark - 点击了 微信支付
- (void)wxPayBtnClick
{
    DLog(@"点击了微信支付");
    
    self.wxResult = [[SNWXSignHttpResult alloc] initWithTarget:self action:@selector(wxSignLoad:)];
    self.wxManager = [SNOrderWXSignDataManager shareManager];
    [self.wxManager requestWXSignWithResult:self.wxResult sn:self.result.model.sn];
}

- (void)wxSignLoad:(SNWXSignHttpResult *)result
{
    if (result.success) {
        
        if ([WXApi isWXAppInstalled]) {//用户安装了微信
            PayReq * wxPayReq = [[PayReq alloc] init];
            wxPayReq.partnerId = result.partnerId;
            wxPayReq.prepayId = result.prepayId;
            wxPayReq.nonceStr = result.nonceStr;
            wxPayReq.timeStamp = [result.timeStamp intValue];
            wxPayReq.sign = result.sign;
            wxPayReq.package = result.packageValue;
            DLog(@"%@",wxPayReq.package);
            
            [WXApi sendReq:wxPayReq];
        } else { //用户没有安装微信
            DLog(@"用户没有安装微信");
            
        }
        
        
    } else if (result.failure) {
        UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:@"提示" message:@"该订单暂无法支付,如有疑问请联系客服" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
        [alertView show];
    }
}

#pragma mark - 点击了 支付宝支付
- (void)zfbPayBtnClick
{
    DLog(@"点击了支付宝支付");
    SNZFBSignHttpResult * result = [[SNZFBSignHttpResult alloc] initWithTarget:self action:@selector(zfbSignLoad:)];
    [self.manager requestZFBSignWithResult:result sn:self.result.model.sn];
}

- (void)zfbSignLoad:(SNZFBSignHttpResult *)result
{
    if (result.success) {
        
        DLog(@"%@",result.newsign);
        
        NSString *orderString = [NSString stringWithFormat:@"%@&sign=\"%@\"&sign_type=\"%@\"",
                                 result.sign, result.newsign, @"RSA"];
        
        NSString *appScheme = @"zfb2088911377642345";
      
        [[AlipaySDK defaultService] payOrder:orderString fromScheme:appScheme callback:^(NSDictionary *resultDic) {
            
            NSString * resultStr;
            
            if (resultDic[@"resultStatus"]) {
                resultStr = [self zfbPayResultWithResultStatus:[resultDic[@"resultStatus"] intValue]];
            }
            
            UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:@"提示" message:resultStr delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
            [alertView show];
            
        }];
        
    } else if (result.failure) {
        UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:@"提示" message:@"该订单暂无法支付,如有疑问请联系客服" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
        [alertView show];
    }
}

#pragma mark - 支付宝的支付结果
- (NSString *)zfbPayResultWithResultStatus:(int)resultStatus
{
    NSString * resultStr;
    switch (resultStatus) {
        case 9000:
            resultStr = kZFBPayResultSuccess;
            break;
           
        case 8000:
            resultStr = kZFBPayResultWaiting;
            break;
            
        case 4000:
            resultStr = @"订单支付失败";
            break;
            
        case 6001:
            resultStr = @"您已取消支付";
            break;
            
        case 6002:
            resultStr = @"网络连接出错";
            break;
            
        default:
            resultStr = @"未知错误";
            break;
    }
    return resultStr;
}

- (void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex
{
    if ([alertView.message isEqualToString:kZFBPayResultSuccess] || [alertView.message isEqualToString:kZFBPayResultWaiting]) {
        //支付成功之后刷新界面
        [self refreshData];
    } else if ([alertView.message isEqualToString:@"确认取消订单"]) {
        if (!buttonIndex) {
            [MBProgressHUD showMBProgressHUBOnWindowsWithMessage:@"取消订单中..."];
            SNCancleOrderHttpResult * result = [[SNCancleOrderHttpResult alloc] initWithTarget:self action:@selector(cancleOrderLoad:)];
            [self.manager requestCancleOrderWithResult:result sn:self.result.model.sn];
        }
    }
}

#pragma mark - 支付宝支付 deletage 回调
- (void)zfbPayResultWithNotification:(NSNotification *)aNotification
{
    NSDictionary * resultDic = aNotification.object;
    NSString * resultStr;
    if (resultDic[@"resultStatus"]) {
        resultStr = [self zfbPayResultWithResultStatus:[resultDic[@"resultStatus"] intValue]];
    }
    
    UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:@"提示" message:resultStr delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
    [alertView show];
}

- (NSString *)wxPayResultWithErrCode:(int)errcode
{
    NSString * resultStr;
    switch (errcode) {
        case -2:
            resultStr = @"您已取消支付";
            break;
            
        default:
            resultStr = kZFBPayResultWaiting;
            break;
    }
    return resultStr;
}

#pragma mark - 微信支付结果回调
- (void)wxPayResultWithNotification:(NSNotification *)aNotification
{
    PayResp *response = aNotification.object;
    
    if (!response) {
        UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:@"提示" message:@"订单支付成功" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
        [alertView show];
        return;
    }
    
    if (response.errCode) {
        NSString * resultStr;
        resultStr = [self wxPayResultWithErrCode:response.errCode];
        UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:@"提示" message:resultStr delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
        [alertView show];
    }
}

#pragma mark - 点击了 商品的cell
- (void)clickGoodsBtn:(SNOrderFormDetailGoodsModel *)detailGoodsModel
{
    HZGoodsDetailViewController * detailVC = [[HZGoodsDetailViewController alloc] init];
    detailVC.shopID = detailGoodsModel.shop_id;
    detailVC.productID = detailGoodsModel.product_id;
    [self.navigationController pushViewController:detailVC animated:YES];
}

#pragma mark - 点击了 评价或者申请售后
- (void)clickBtnWithTitle:(NSString *)title row:(NSInteger)row
{
    if ([title isEqualToString:kCommentBtnTitle]) {//点击了评价按钮
        SNAddCommentsViewController * addCommentsVC = [[SNAddCommentsViewController alloc] init];
        addCommentsVC.sn = self.result.model.sn;
        addCommentsVC.listModel = self.result.model.productArray[row];
        [self.navigationController pushViewController:addCommentsVC animated:YES];
    } else if ([title isEqualToString:kReturnGoodsBtnTitle]) {
        SNOrderFormDetailGoodsModel * listModel = self.result.model.productArray[row];
        if (listModel.returnGoodsBtnType == ReturnGoodsReturnApply) {// 首次 申请售后
            SNReturnGoodsViewController * returnGoodsVC = [[SNReturnGoodsViewController alloc] init];
            returnGoodsVC.sn = self.result.model.sn;
            returnGoodsVC.receiverName = self.result.model.receiverInfoModel.receiver;
            returnGoodsVC.isReturns = self.result.model.isReturns;
            returnGoodsVC.ostatus = self.result.model.ostatus;
            returnGoodsVC.timeStr = self.result.model.createTime;
            returnGoodsVC.receiverPhoneNum = self.result.model.receiverInfoModel.phone;
            returnGoodsVC.popToVCNameStr = @"SNOrderFormDetailViewController";
            returnGoodsVC.listModel = listModel;
            [self.navigationController pushViewController:returnGoodsVC animated:YES];
        } else if (listModel.returnGoodsBtnType == ReturnGoodsReturnAdd) { // 多次 申请售后
            SNReturnGoodsRepetitiousViewController * returnGoodsRepetitionsVC = [[SNReturnGoodsRepetitiousViewController alloc] init];
            returnGoodsRepetitionsVC.sn = self.result.model.sn;
            returnGoodsRepetitionsVC.productId = listModel.product_id;
            returnGoodsRepetitionsVC.receiverPhoneNum = self.result.model.receiverInfoModel.phone;
            returnGoodsRepetitionsVC.listModel = listModel;
            [self.navigationController pushViewController:returnGoodsRepetitionsVC animated:YES];
        }
    }
}

#pragma mark - 点击了 赠品
- (void)clickGiftBtnWithDetailGoodsModel:(SNOrderFormDetailGoodsModel *)detailGoodsModel
{
    HZProductGiftListView *giftListView = [[HZProductGiftListView alloc] initWithGift:detailGoodsModel.giftModel promotions:nil url:detailGoodsModel.title_pic price:detailGoodsModel.sale_price title:detailGoodsModel.product_title spec:nil];
    [giftListView showGiftListView];
}

- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"refreshOrderFormDetail" object:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
